<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('运营机构')" />
	<th:block th:include="include :: list-css" />
	<style type="text/css">
		.tccon label.layui-form-label {width: 150px;padding-right: 0px;}
		.tccon .layui-input-block{margin-left: 150px;}
		.layui-form-radio {margin-top:0}
		.importTable{empty-cells:show;border-collapse:collapse;border-spacing:0;}
		.listext th{background:#eee;color:#3366cc;}
		.listext th,.listext td{border:solid 1px #ddd;text-align:left;padding:10px;font-size:14px;}
		
		#importProgress {z-index:20200202;background-color: #000;opacity: 0.3;display:none;}
		.importProgress {width:300px;z-index:20202222;position: fixed;top: 34%;left: 40%;display:none;}
		/* .layui-table-box{overflow-x: auto !important;}
		.layui-table-header{display: inline-block !important;} */
	</style>
</head>
<body>
<div class="main-content">
	<div class="content-right">
		<div class="search-top">
			<span>查询条件</span>
			<a href="javascript:;" layadmin-event="flexible" class="menuBtn">
				<i class="layui-icon layui-icon-spread-left" id="LAY_app_flexible" style="color: #fff;"></i>
			</a>
		</div>
		<div class="panel layout-expand layui-expand-east">
		    <div class="panel-header">
		        <div class="panel-tool" style="text-align: center; width: 26px;height: 30px;line-height: 30px;">
		            <a href="javascript:;" layadmin-event="flexible" class="menuBtn">
		                <i class="layui-icon layui-icon-shrink-right" id="LAY_app_flexible" style="color: #fff;"></i>
		            </a>
		        </div>
		    </div>
		    <div class="panel-body panel-title" style="text-align: center; width: 26px;">查<br>询<br>条<br>件</div>
		</div>
       	<form class="layui-form">
			<th:block th:include="listinclude :: searchRight('page')" />
		</form>
   	</div>
    <div class="mid-content">
		<table class="layui-hide" id="dhtable" lay-filter="ftable"></table>
	</div>
</div>
<!-- 表格头部工作栏-->
<script type="text/html" id="toolbar">
	<div class="layui-btn-container">
		<!-- <div class="layui-btn layui-table-tools importbtn-bg" lay-event="addbtn" shiro:hasPermission="hr:operatecompanyroute:add">
			<i class="dhicon dh-plus"></i> 新增
        </div> -->
		<!-- <div class="layui-btn layui-btn-danger layui-table-tools" onclick="remove()" shiro:hasPermission="hr:operatecompanyroute:delete">
            <p class="dhicon dh-remove" style="color:white;font-size:14px"><span class="fa_span">批量删除</span></p>
        </div> -->
		<div class="layui-btn layui-table-tools importbtn-bg" lay-event="exportbtn" shiro:hasPermission="hr:operatecompanyroute:export">
			<i class="dhicon dh-download"></i> 导出
        </div>
    </div>
</script>

<!-- 表格操作区 -->
<script type="text/html" id="barDh">
    <a class="layui-btn layui-btn-danger layui-btn-xs dhicon" lay-event="bjbtn" shiro:hasPermission="hr:operatecompanyroute:edit">&nbsp;编辑</a>
</script>
<!-- 表格操作区 -->
<script type="text/html" id="yybl">
	<div class="layui-form layui-card-header layuiadmin-card-header-auto tccon">
		<div class="layui-form-item margin_t0">
			<input  type="hidden"  name="guid1" id="guid1"  th:value="${ratio?.guid}" class="layui-input canntEdit" autocomplete="off" readonly/>
	        <div class="layui-inline margin_r0 layui-col-xs12">
	        	<label class="layui-form-label"><font class="f_red">*</font><font>基础运营比例(%)：</font></label>
				<div class="layui-input-block"><input  type="number"  name="vJcBl1" id="vJcBl1" th:value="${ratio?.vJcBl}" class="layui-input" autocomplete="off"/></div>
			</div>
			<div class="layui-inline margin_r0 layui-col-xs12">
	        	<label class="layui-form-label"><font class="f_red">*</font><font>回款数(元)：</font></label>
				<div class="layui-input-block"><input  type="number"  name="vHks1" id="vHks1" th:value="${ratio?.vHks}" class="layui-input" autocomplete="off"/></div>
			</div>
			<div class="layui-inline margin_r0 layui-col-xs12">
	        	<label class="layui-form-label"><font class="f_red">*</font><font>回款数浮动比例(%)：</font></label>
				<div class="layui-input-block"><input  type="number"  name="vHkBl1" id="vHkBl1" th:value="${ratio?.vHkBl}" class="layui-input" autocomplete="off"/></div>
			</div>
			<div class="layui-inline margin_r0 layui-col-xs12">
	        	<label class="layui-form-label"><font class="f_red">*</font><font>店铺数运营比例(%)：</font></label>
				<div class="layui-input-block"><input  type="number"  name="vDpYyBl1" id="vDpYyBl1" th:value="${ratio?.vDpYyBl}" class="layui-input" autocomplete="off"/></div>
			</div>
			<div class="layui-inline margin_r0 layui-col-xs12">
	        	<label class="layui-form-label"><font class="f_red">*</font><font>店铺数浮动比例(%)：</font></label>
				<div class="layui-input-block"><input  type="number"  name="vDpFdBl1" id="vDpFdBl1" th:value="${ratio?.vDpFdBl}" class="layui-input" autocomplete="off"/></div>
			</div>
		</div>
	</div>
</script>


<th:block th:include="include :: footer" />
<th:block th:include="include :: businessJS" />
<th:block th:include="include :: searchJS" />
<th:block th:include="listinclude :: list-templeat" />
<script th:inline="javascript">
	/*<![CDATA[*/
	var prefix = ctx + "hr/operatecompanyroute";
	var gridColumns = [[${gridColumns}]], 
	    importFields =[[${importFields}]],
		ratio =[[${ratio}]],
		moduleTable =[[${moduleTable}]];
	/*]]>*/
</script>
<script type="text/javascript">
var element,thStr;
var fieldWidth = {},		//导入列表字段宽度
	filedRequired = {},		//导入列表必填字段
	dateFiled = [],			//导入列表日期字段
	hasNull = false;		//导入数据必填字段有空值
$.each(gridColumns.dictionaryForPageFieldList,function(i,v){
	fieldWidth[v.fields] = v.fieldFrontWidth
	if(v.fieldFrontRequired)filedRequired[v.fields] = v.fieldName;
	if(v.fieldFrontType == 't_date')dateFiled.push(v.fields);
})
var $,layer,laydate,form,table,wherestr={};
layui.use(['table','laydate','form','layer','jquery','element'], function () {
	$ = layui.$, layer = layui.layer,laydate = layui.laydate , form = layui.form, table = layui.table, element = layui.element;
	serachRender();//查询条件初始渲染集合
	changeDropdown('fSl');//导入窗口——税率下拉可编辑赋事件
	$.tablelist.init({
		elem: '#dhtable'
		,modalName: "产品信息"
		,url: prefix + '/list'
		,updateUrl: prefix + "/edit?guid={id}"
		,totalRow: gridColumns.totalRow
		,cols: [gridColumns.gridBody]
		,toolbar: '#toolbar'
		,defaultToolbar: [{title:'列设置',layEvent: 'fieldSet',icon: 'layui-icon-set'}] //这里在右边显示
		,height:'full-65'
        ,parseData: function(res){ //res 即为原始返回的数据
			var objpage=sessionStorage.getItem(moduleTable+'checkdata')
			if(objpage){
				objpage=JSON.parse(objpage)
				res.data.map((v,i)=>{
					objpage.map((n,m)=>{
						 if(v.guid==n.guid){
							v.LAY_CHECKED=true
						 }
					})
				})
			}
		}
	});

	//监听表格工具条
	table.on('tool(ftable)', function (obj) {
        var data = obj.data;
        if(obj.event === 'bjbtn'){ //tr编辑按钮
           console.log(obj)
		   var trData=obj.data
		   layer.open({
               type: 1,
               content:`<div class="layui-form layui-card-header layuiadmin-card-header-auto tccon">
	                    	<div class="layui-form-item margin_t0">
								<input  type="hidden"  name="guid" id="guid"  value="${trData.guid}" class="layui-input canntEdit" autocomplete="off" readonly/>
	                            <div class="layui-inline margin_r0 layui-col-xs12">
	                            	<label class="layui-form-label"><font>公司名称：</font></label>
	                    			<div class="layui-input-block"><input  type="text" name="vGsJc" id="vGsJc" value="${trData.vGsJc}" class="layui-input canntEdit" autocomplete="off" readonly/></div>
	                    		</div>
	                    		<div class="layui-inline margin_r0 layui-col-xs12">
	                            	<label class="layui-form-label"><font>公司编码：</font></label>
	                    			<div class="layui-input-block"><input  type="text" name="vGsBm" id="vGsBm" value="${trData.vGsBm}" class="layui-input canntEdit" autocomplete="off" readonly/></div>
	                    		</div>
	                    		<div class="layui-inline margin_r0 layui-col-xs12">
	                            	<label class="layui-form-label"><font>基本比例(%)：</font></label>
	                    			<div class="layui-input-block"><input  type="number" name="vJcBl" id="vJcBl" value="${trData.vJcBl}" class="layui-input canntEdit" autocomplete="off" readonly/></div>
	                    		</div>
	                    		<div class="layui-inline margin_r0 layui-col-xs12">
	                            	<label class="layui-form-label"><font>运营比例(%)：</font></label>
	                    			<div class="layui-input-block"><input  type="number" name="vYyBl" id="vYyBl" value="${trData.vYyBl}" class="layui-input canntEdit" autocomplete="off" readonly/></div>
	                    		</div>
	                    		<div class="layui-inline margin_r0 layui-col-xs12">
	                            	<label class="layui-form-label"><font>机构名称：</font></label>
	                    			<div class="layui-input-block"><input  type="text" name="orgName" id="orgName1" value="${trData.orgName}" class="layui-input" autocomplete="off"/></div>
	                    		</div>
	  
	                    		<div class="layui-inline margin_r0 layui-col-xs12">
	                            	<label class="layui-form-label"><font class="f_red">*</font><font>特殊比例(%)：</font></label>
	                    			<div class="layui-input-block"><input  type="number" name="vTsBl" id="vTsBl" value="${trData.vTsBl}" class="layui-input" autocomplete="off"/></div>
	                    		</div>
	                    	</div>
	                    </div>`,
			   area: ['500px', '330px'],
			   maxmin: true,
               shade: 0.3,
			   title: '编辑',
			   shadeClose: true,
			   btn: ['确定', '关闭'],
			   yes: function(index, layero){
				    var guid=$('#guid').val();
					if(guid=="null"){guid=""}
				    var vGsBm=$('#vGsBm').val();
				    var vJcBl=$('#vJcBl').val();
				    var vYyBl=$('#vYyBl').val();
				    var vTsBl=+$('#vTsBl').val();
					if(vTsBl){
						if(vTsBl<0 || vTsBl>100)return layer.msg('特殊比例区间为[0,100]之前')
					}else{
						if(vTsBl!=0)return layer.msg('请填写必填项')
					}
					
				    var orgName = $('#orgName1').val();
					// return;
					$.post(prefix + "/editpost",{'infoItems':JSON.stringify([{guid,vGsBm,vJcBl,vYyBl,orgName,vTsBl}])},function(res){
						layer.msg(res.msg)
			        	if(res.code==0){
							layer.closeAll()
			                table.reload('dhtable');
			            }
			        });
                }
             });
        };
    });
    
	//监听排序事件 
	table.on('sort(ftable)', function(obj){
		$.tablelist.sort('dhtable',obj);
	});

	//头工具栏事件
 	table.on('toolbar(ftable)', function(obj){
 	    switch(obj.event){
	   		case 'exportbtn':
		   		$.ajax({
		   		    url: '/hr/operatecompanyroute/export',
		   		    type: 'GET',
		   		    data: getWherestr(),
		   		    dataType: 'json',
		   		    beforeSend: function(){
			   			showloadings(true);
		   		    },
		   		    success: function(result){
		   		    	if (result.code == 0) {
					        window.location.href = ctx + "common/download?fileName=" + encodeURIComponent(result.msg) + "&delete=" + true;
					        parent.$('.page-loading').hide();//页面进行了跳转刷新，需要手动关闭页面的加载动画
						} else if (result.code == web_status.WARNING) {
		                   $.modal.alertWarning(result.msg)
		            	} else {
							$.modal.alertError(result.msg);
						}
				   		showloadings(false);
		   		    }
		   		});
	   		break;
			case 'tableFull'://表格展开
				$('.north .layui-form').hide();
				table.reload('dhtable',{
					defaultToolbar: [{title:'收缩',layEvent:'tableShrink',icon:'layui-icon-screen-restore'}],
					height: $(window).height()-$('.north').height()-60<300?'300':$(window).height()-( $('.north').height()+$('.south').height()+12)
				});
			break;
			case 'tableShrink'://表格收缩
				$('.north .layui-form').show();
				table.reload('dhtable',{
					defaultToolbar: [{title:'展开',layEvent:'tableFull',icon:'layui-icon-screen-full'}],
					height: $(window).height()-$('.north').height()-60<300?'300':$(window).height()-( $('.north').height()+$('.south').height()+12)
				});
			break;
	 	    case 'fieldSet':
 	    		filedSet(moduleTable);
          	break;
 	    };
 	});
 });


//通过guid彻底删除
function remove(guid,code){
	if(guid){
		$.operate.remove("该删除无法恢复，请确认？",prefix + "/delete/",{'infoItems':JSON.stringify([{'guid':guid,code}])},function(result){
			if(result.code==0){
		        setTimeout(function(){
		            layer.closeAll();
		            table.reload('dhtable');
		        }, 1000);
		    }
		});
	}else{
		if(table.checkStatus('dhtable').data.length>0){
			$.operate.remove("是否彻底删除该"+table.checkStatus('dhtable').data.length+"条产品？",prefix + "/delete/",{'infoItems':JSON.stringify(table.checkStatus('dhtable').data, null, 2)},function(result){
				if(result.code==0){
			        setTimeout(function(){
			            layer.closeAll();
			            table.reload('dhtable');
			        }, 1000);
			    }
			});
		}else{
			layer.msg("无勾选数据！");
		};
	}
}

</script>
</body>
</html>